package models

import (
	"time"
)

type Upload struct {
	Id       int       `xorm:"not null pk autoincr comment('文件编号') INT(11)"`
	FileType string    `xorm:"comment('文件类型') ENUM('classroom','coachfp','coachimg','epdfimg','examinerfp','examinerimg','occupationimg','onlineimg','outletsimg','securityguardfg','securityguardimg','simulation','stufp','stuimg','vehimg','video','voiceprintimg')"`
	FileUrl  string    `xorm:"not null comment('文件地址') VARCHAR(256)"`
	ClientIp string    `xorm:"comment('上传者ip') VARCHAR(20)"`
	AddTime  time.Time `xorm:"not null comment('上传时间') DATETIME"`
}

func (c *Upload) GetPortraitById(id int64) (has bool, list Upload, err error) {
	if has, err = engine.Table("dts_upload").
		Where("id = ?", id).
		Get(&list); err != nil {
		return has, list, err
	}
	return has, list, nil
}

func (c *Upload) Add() bool {
	if _, err := engine.Insert(c); err != nil {
		return false
	}
	return true
}
